package org.demo.work;


/**
 * 任务监听
 * @author  
 * @date    2010-10-27
 * @file    org.demo.work.LogWorkListener.java
 */
public class LogWorkListener implements WorkListener{
	
	@Override
	public void workAccepted(WorkEvent event) {
		Work work = event.getWork();
		System.out.println("work " + work.getName() + " accepted.");
	}	
	
	@Override
	public void workStarted(WorkEvent event) {
		Work work = event.getWork();
		System.out.println("work " + work.getName() + " started.");
	}
	
	@Override
	public void workCompleted(WorkEvent event) {
		Work work = event.getWork();
		if (event.getException() == null){
			System.out.println("work " + work.getName() + " completed.");
		} else {
			System.out.println("work " + work.getName() + " completed with exception " + event.getException().getMessage());
		}
	}
}
